<?php
$quantities = range(1, $model->quantity);
$quantityList = CHtml::dropDownList('quantity', 1, array_combine($quantities, $quantities), array(
		'style' => 'display: inline; margin-right: 10px'
	));
$userId = Yii::app()->user->id;
?>

<div class="row">
    <div class="six columns">
		<h1><?php echo "$model->name \$$model->price"; ?></h1>
		<?php
		$folder = $model->getImageFolder();
		echo CHtml::image(Yii::app()->baseUrl . "/uploads/fullsize/$model->id.jpg", $model->description);
		?>
		<p class="lead"><b><?php echo CHtml::link($model->user->name, array('user/view', 'id' => $model->user_id)) ?></b></p>
		<p><?php echo $model->description ?></p>

		<?php if ($userId != $model->user_id && $model->quantity != 0) { ?>
			<div class="row">
				<form class="nice" action="<?php echo $this->createUrl('user/AddCart', array('id' => $model->id)) ?>">
                                    <p><b>Quantity</b>
					<?php
                                        echo $quantityList;
					echo CHtml::submitButton('Add to Shopping Cart', array(
						'class' => 'nice blue radius button'
					));
					?>
                                    </p>
				</form>

				<form class="nice" action="<?php echo $this->createUrl('buy', array('id' => $model->id)) ?>">
					<p><b>Quantity</b>
						<?php
						echo $quantityList;
						echo CHtml::submitButton('Buy Item', array(
							'class' => 'nice blue radius button'
						));
						?>
					</p>
				</form>
			</div>
		<?php } ?>


	</div>
	<div class="six columns">
		<div class="row">
			<div class="six columns">
				<?php
				if ($userId == $model->user_id) {
					echo CHtml::link('Update Item', array('update', 'id' => $model->id), array(
						'class' => 'nice white radius button'
					));
				}
				?>
			</div>
			<form class="six columns" action="<?php echo $this->createUrl('item/delete', array('id' => $model->id)); ?>">
				<?php
				if ($userId == $model->user_id) {
					echo $quantityList;
					echo CHtml::submitButton('Delete Item(s)', array(
						'class' => 'nice red radius button'
					));
				}
				?>
			</form>
		</div>
		<div class="row">
			<br />
			<div class="commentborder">
				<?php $this->widget('application.components.Commentlist', array('item' => $model)); ?>
			</div>
		</div>
		<?php if (true) { ?>
			<div class="row">
				<br />
				<!-- G+ -->
				<g:plusone annotation="inline" width="120"></g:plusone>
				<script type="text/javascript">
					(function() {
						var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
						po.src = 'https://apis.google.com/js/plusone.js';
						var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
					})();
				</script>

				<!-- facebook -->
				<iframe src="//www.facebook.com/plugins/like.php?href&amp;send=false&amp;layout=button_count&amp;width=120&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe>

				<!-- twitter -->
				<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
				<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
			</div>
		<?php } ?>
	</div>
</div>
